package com.nimitz.factorEquipment.service.serviceImpl;


import com.nimitz.factorEquipment.domain.*;
import com.nimitz.factorEquipment.mapper.EquipmentMapper;
import com.nimitz.factorEquipment.service.EquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EquipmentServiceImpl implements EquipmentService {
    @Autowired
    private EquipmentMapper equipmentMapper;

    @Override
    public List<Equipment> getAllEquipments(Equipment equipment) {
        return equipmentMapper.selectAllEquipments(equipment);
    }

    @Override
    public void addEquipment(Equipment equipment) {
        equipmentMapper.insertEquipment(equipment);
    }

    @Override
    public Equipment selectEquipmentById(Long id) {
       return equipmentMapper.selectEquipmentId(id);
    }

    @Override
    public void updateEquipment(Equipment equipment) {
        equipmentMapper.updateEquipment(equipment);
    }

    @Override
    public void deleteEquipment(Long id) {
        equipmentMapper.deleteEquipment(id);
    }
//    @Override
//    public List<EquipmentDetail> getAllEquipmentDetails(String equipmentTypeId) {
//        return equipmentMapper.selectAllEquipmentDetails(equipmentTypeId);
//    }


    // 新增方法：根据equipment_type_id查询设备名称和关联的factor_id和value
    @Override
    public List<EquipmentDetail> getEquipmentDetailsId(Long equipmentId) {
        return equipmentMapper.selectEquipmentDetailsId(equipmentId);
    }

    //查询所有设备类型名称
    @Override
    public List<EquipmentType> selectAllEquipmentTypes() {
        return equipmentMapper.selectAllEquipmentTypes();
    }

    @Override
    public List<Section> selectAllSections() {
        return equipmentMapper.selectAllSections();
    }

    //查询省
    @Override
    public List<Area> getProvinces() {
        return equipmentMapper.getProvinces();
    }
    //根据省查询市
    @Override
    public List<Area> getCitiesByProvinceId(Long provinceId) {
        return equipmentMapper.getCitiesByProvinceId(provinceId);
    }
    //  根据市查询区
    @Override
    public List<Area> getDistrictsByCityId(Long cityId) {
        return equipmentMapper.getDistrictsByCityId(cityId);
    }

    @Override
    public List<River> getRiversByDistrictId(Long areaId) {
        return equipmentMapper.getRiversByDistrictId(areaId);
    }

    @Override
    public List<Section> getSectionsByRiverId(Long riverId) {
        return equipmentMapper.getSectionsByRiverId(riverId);
    }
}
